package com.example.index.system.toy

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.widget.FrameLayout

class FooFrameLayout : FrameLayout {

    val TAG = "FooFrameLayout"

    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)


    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        Log.i(TAG, "$this onInterceptTouchEvent: ${actionString(ev)}")
        return super.onInterceptTouchEvent(ev)
    }

    fun actionString(ev: MotionEvent?): String {
        return when (ev?.action) {
            MotionEvent.ACTION_DOWN -> "down"
            MotionEvent.ACTION_MOVE -> "move"
            MotionEvent.ACTION_UP -> "up"
            else -> "none"

        }

    }
}